package com.gameserver;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException
	{
		GameSocketServer game;
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		boolean exit = false;

		game = new GameSocketServer(80);
//		while(game.connection == null)
//		{
//			game.getConnection();
//		}
		
		while(!exit){
			//try{	
				game.getConnection();
				//game.setupStreams();
				game.recieveData();
//			}catch(IOException e){
//				e.printStackTrace();
//				System.exit(1);
//			} 

		if(reader.ready()){
				exit = reader.readLine().contains("quit");	
			}
		}
		
		System.out.println("Closing Connections");
		game.closeConnections();
		System.exit(0);
	}
}
